////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "WNScripting/inc/WNParseNode.h"

WNParseNode::WNParseNode(WN_SIZE_T _startLine, WN_SIZE_T _endLine, WN_SIZE_T _startChar, WN_SIZE_T _endChar):
	mStartLine(_startLine),
	mEndLine(_endLine),
	mStartChar(_startChar),
	mEndChar(_endChar),
    mOptimized(WN_FALSE),
    mGenerated(WN_FALSE),
    mFail(WN_NULL),
    mWarning(WN_NULL) {
}

WNParseNode::~WNParseNode() {
}

llvm::Value* WNParseNode::OptimizeAndGenerate(WNScriptingEngineData& _scriptingData, WNFunctionDecl* _functionDecl) {
    mOptimized = WN_TRUE;
    mGenerated = WN_TRUE;
    return(WN_NULL);
}

WN_BOOL WNParseNode::ReportErrors() {
    if (mWarning) {
        fprintf(stderr, "Warning %s:%d[%d]\n", mWarning, mStartLine, mStartChar);
    }
    
    if (mFail) {
        fprintf(stderr, "Error %s:%d[%d]\n", mFail, mStartLine, mStartChar);
    }
    return(mFail != WN_NULL);
}
